package com.jml.zlhq.app.ui;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.youmi.android.AdManager;
import net.youmi.android.offers.OffersManager;

import org.apache.http.Header;
import org.json.JSONObject;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import cn.dow.android.DOW;
import cn.sharesdk.framework.ShareSDK;
import cn.waps.AppConnect;

import com.bb.dd.BeiduoPlatform;
import com.chuannuo.tangguo.TangGuoWall;
import com.dc.wall.DianCai;
import com.dlnetwork.DevInit;
import com.igexin.sdk.PushManager;
import com.jml.zlhq.app.AppConfig;
import com.jml.zlhq.app.R;
import com.jml.zlhq.app.URLs;
import com.jml.zlhq.app.service.HttpService;
import com.jml.zlhq.app.ui.LoginActivity.CheckBind;
import com.jml.zlhq.app.util.BaseTools;
import com.jml.zlhq.app.util.StringUtil;
import com.jml.zlhq.app.util.UIUtil;
import com.jml.zlhq.app.util.UpdateManager;
import com.loopj.android.http.TextHttpResponseHandler;
import com.newqm.pointwall.QSdkManager;
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
import com.nostra13.universalimageloader.utils.StorageUtils;
import com.yql.dr.sdk.DRScoreInterface;
import com.yql.dr.sdk.DRSdk;
import com.zkmm.appoffer.OfferListener;
import com.zkmm.appoffer.ZkmmAppOffer;
import com.zy.phone.SDKInit;

public class MainActivity extends BaseFragmentActivity implements
		DRScoreInterface, OfferListener {
	private TextView textView1, textView2, textView3, textView4;
	private int currIndex;
	// private int offset = 0;// 动画图片偏移量
	// private int bmpW;// 动画图片宽度
	private static LingGanFragment fragment1;
	private static FaXianFragment fragment2;
	private static TanDianFragment fragment3;
	// private static WodeFragment fragment4;
	private static FenxianZuanFragment fragment4;

	// 我的改为分享赚

	// private DrawerLayout mDrawerLayout;

	private RelativeLayout appStart;
	private ImageView appStartIco;
	private TextView appStartText;
	private ViewPager appSplash;
	private View appSpBack;

	@SuppressLint("HandlerLeak")
	private Handler mHandler = new Handler() {
		@Override
		public void handleMessage(Message msg) {
			switch (msg.what) {
			case 1:
				final int totalPoints = msg.getData().getInt("totalPoints");
				final Map<String, String> sbmap = new HashMap<String, String>();
				sbmap.put("access-token", appContext.getLoginUid());
				sbmap.put("coinnum", String.valueOf((int) totalPoints));
				HttpService.postByText(URLs.USER_POINT_ADD, sbmap,
						new TextHttpResponseHandler() {
							@Override
							public void onSuccess(int arg0, Header[] arg1,
									String result) {
								try {
									JSONObject json = new JSONObject(result);
									Log.e("==vcode==", result);
									if (BaseTools.getFrom("status", json)
											.equals("0")) {
										com.baidu.mobads.appoffers.OffersManager
												.subPoints(MainActivity.this,
														totalPoints);
										LoginActivity.afterLogined(
												MainActivity.this,
												new CheckBind() {
													@Override
													public void checkBind(
															String phone) {
														// TODO
													}
												});
										return;
									}
								} catch (Exception e) {
								}
							}

							@Override
							public void onFailure(int arg0, Header[] arg1,
									String arg2, Throwable arg3) {

							}
						});
				break;
			}
		}
	};

	//
	// @SuppressWarnings("unused")
	// private static final int[] pics = { R.drawable.sl01,R.drawable.sl03,
	// R.drawable.sl04, R.drawable.sl05, R.drawable.sl06 };

	public void initChannel() {

		Log.i("ZLHQ", "initChannel");
		Log.i("ZLHQ", "Uid:" + appContext.getLoginUid());
		// 多盟
		DOW.getInstance(this).init();
		DOW.getInstance(this).setUserId(appContext.getLoginUid());
		// 贝多
		BeiduoPlatform.setAppId(this, "14265", "15252818b0f1114");
		BeiduoPlatform.setUserId(appContext.getLoginUid());
		// 有米
		// userid 不能为空 或者 空串,否则设置无效, 字符串长度必须要小于50
		OffersManager.getInstance(this).setCustomUserId(
				appContext.getLoginUid());
		// 有米Android SDK v4.10之后的sdk还需要配置下面代码，以告诉sdk使用了服务器回调
		OffersManager.setUsingServerCallBack(true);
		AdManager.getInstance(this).init(AppConfig.APP_ADS_YOUMI_APPID,
				AppConfig.APP_ADS_YOUMI_APPSECRET, false);
		OffersManager.getInstance(this).onAppLaunch();
		// 百度联盟
		com.baidu.mobads.appoffers.OffersManager.setUserName(this,
				appContext.getLoginUid());
		// 设置积分监听接口 subPoints、addPoints、getPoints方法调用在PointsUpdateListener中返回结果

		// 初始化 万普
		AppConnect.getInstance(this);
		// 初始化 点入
		DRSdk.initialize(activity, true, appContext.getLoginUid());

		// 点财

		DianCai.initApp(this, "14605", "391f97472feb475eadb70f2c8dd91711");
		DianCai.setUserId(appContext.getLoginUid());
		// 安沃
		ZkmmAppOffer appOffer = ZkmmAppOffer.getInstance(this,
				"3ff72c43e7d4426392b1fd561bff527d");
		appOffer.setOfferListener(this);

		// 中亿
		/*
		 * 初始化信息 AdpCode 是开发者的秘钥 other 用户ID，用于记录开发者应用的唯一用户标识,没有为空
		 */
		SDKInit.initAd(this, "3b45c0e2ca4cd259", appContext.getLoginUid());
		// 点乐
		DevInit.initGoogleContext(this, "f26bfd8a48931c3cc77f7f70bd015f2d",
				appContext.getLoginUid());
		DevInit.setCurrentUserID(this,appContext.getLoginUid());
		// 糖果
		TangGuoWall.init(this, appContext.getLoginUid());
		// 趣米
		QSdkManager.init(this, "34b5268b5fa00d9c", "34079a8e0ce8e7d1",
				appContext.getLoginUid(), appContext.getLoginUid());
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		appContext.cityId = appContext.getProperty("city_id");
		appContext.cityName = appContext.getProperty("city_name");
		if (StringUtil.isEmpty(appContext.cityName))
			appContext.cityName = "全国";
		if (StringUtil.isEmpty(appContext.cityId))
			appContext.cityId = "";

		UIUtil.setWinWidthHight(this);
		File images = StorageUtils.getOwnCacheDirectory(
				getApplicationContext(), AppConfig.APP_IMAGE);

		// 初始化图片加载库
		DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
				.showImageOnLoading(R.drawable.ic_launcher)
				.showImageForEmptyUri(R.drawable.ic_launcher)
				.showImageOnFail(R.drawable.ic_launcher)
				.showImageForEmptyUri(R.drawable.ic_launcher).cacheOnDisk(true)
				.cacheInMemory(true).displayer(new FadeInBitmapDisplayer(0))
				.imageScaleType(ImageScaleType.IN_SAMPLE_INT)// 设置图片以如何的编码方式显示
				.bitmapConfig(Bitmap.Config.RGB_565)// 设置图片的解码类型//
				.build();
		ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
				getApplicationContext())
				.memoryCacheExtraOptions(UIUtil.winWidth, UIUtil.winHight)
				.memoryCache(new WeakMemoryCache())
				.threadPoolSize(3)
				// 线程池内加载的数量
				.threadPriority(Thread.NORM_PRIORITY - 2)
				.denyCacheImageMultipleSizesInMemory()
				.memoryCacheSize(8 * 1024 * 1024)
				.diskCacheSize(50 * 1024 * 1024)
				.diskCacheFileNameGenerator(new Md5FileNameGenerator())
				// 将保存的时候的URI名称用MD5 加密
				.tasksProcessingOrder(QueueProcessingType.LIFO)
				.diskCacheFileCount(100) // 缓存的文件数量
				.diskCache(new UnlimitedDiskCache(images))// 自定义缓存路径
				.defaultDisplayImageOptions(defaultOptions).build();
		ImageLoader.getInstance().init(config);

		ShareSDK.initSDK(this);
		ShareSDK.setConnTimeout(20000);
		ShareSDK.setReadTimeout(20000);

		// 个推
		PushManager.getInstance().initialize(this.getApplicationContext());

		appStart = (RelativeLayout) findViewById(R.id.splash_image);
		appStartIco = (ImageView) findViewById(R.id.splash_back_ico);
		appStartIco.setPadding(0, 0, 0, UIUtil.winHight * 3 / 7);
		appStartText = (TextView) findViewById(R.id.splash_back_text);
		RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(
				LayoutParams.MATCH_PARENT, (UIUtil.winWidth * 253 * 3)
						/ (720 * 4));// UIUtil.winWidth*235/480
		rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
		appStartText.setLayoutParams(rlp);
		appStartText.setGravity(Gravity.CENTER);
		String vsn = "";
		try {
			PackageInfo info = getPackageManager().getPackageInfo(
					getPackageName(), 0);
			vsn = info.versionName;
		} catch (NameNotFoundException e) {
			e.printStackTrace();
		}
		appStartText.setText("赚零花钱  " + vsn);
		appSplash = (ViewPager) findViewById(R.id.splash_viewpager);
		appSpBack = findViewById(R.id.splash_back);
		appSplash.setVisibility(View.GONE);
		appSpBack.setVisibility(View.VISIBLE);
		appStart.setVisibility(View.VISIBLE);
		// String first =
		// AppConfig.getAppConfig(activity).get("APP_IS_FIRST_START");
		// if(StringUtil.isEmpty(first)||!first.equals("yes")){
		// appSplash.setVisibility(View.VISIBLE);
		// List<View> linked = new LinkedList<View>();
		// for (int j = 0; j < pics.length; j++) {
		// if(j==pics.length-1){
		// View view = LayoutInflater.from(this).inflate(R.layout.splash_0,
		// null);
		// RelativeLayout.LayoutParams lp = new
		// RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
		// lp.setMargins(0, UIUtil.winHight*58/78, 0, 0);
		// View enter = view.findViewById(R.id.ap0_b);
		// enter.setLayoutParams(lp);
		// enter.setOnClickListener(new OnClickListener() {
		// @Override
		// public void onClick(View v) {
		// AppConfig.getAppConfig(activity).set("APP_IS_FIRST_START","yes");
		// appSplash.setVisibility(View.GONE);
		// loadData(null);
		// }
		// });
		// linked.add(view);
		// continue;
		// }
		// ImageView img = new ImageView(activity);
		// LinearLayout.LayoutParams lp = new
		// LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);
		// img.setLayoutParams(lp);
		// img.setScaleType(ScaleType.FIT_XY);
		// img.setImageResource(pics[j]);
		// linked.add(img);
		// }
		// appSplash.setAdapter(new ViewPagerAdapter(linked));
		//
		// }else{
		// loadData(null);
		// }

		loadData(null);

		// mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
		textView1 = (TextView) findViewById(R.id.main_fragment_linggan);
		textView2 = (TextView) findViewById(R.id.main_fragment_faxian);
		textView3 = (TextView) findViewById(R.id.main_fragment_tandian);
		textView4 = (TextView) findViewById(R.id.main_fragment_wode);

		// mDrawerLayout.setDrawerShadow(R.drawable.shadow,
		// GravityCompat.START);

		textView1.setOnClickListener(this);
		textView2.setOnClickListener(this);
		textView3.setOnClickListener(this);
		textView4.setOnClickListener(this);

		// LoginActivity.pushPoint(activity);

		// GradientDrawable gd = new GradientDrawable();//创建drawable
		// gd.setColor(getResources().getColor(R.color.color_e95847));
		// gd.setSize(UIUtil.winWidth/4, UIUtil.dip2px(appContext, 4));
		// bmpW = UIUtil.winWidth/4;// 获取图片宽度
		// DisplayMetrics dm = new DisplayMetrics();
		// getWindowManager().getDefaultDisplay().getMetrics(dm);
		// int screenW = dm.widthPixels;// 获取分辨率宽度
		// offset = (screenW / 4 - bmpW) / 2;// 计算偏移量
		// Matrix matrix = new Matrix();
		// matrix.postTranslate(offset, 0);
		textView1.setTextColor(getResources().getColor(R.color.color_e95847));
		Drawable drawable1 = getResources().getDrawable(
				R.drawable.ico_linggan_sel);
		drawable1.setBounds(0, 0, drawable1.getMinimumWidth(),
				drawable1.getMinimumHeight());
		textView1.setCompoundDrawables(null, drawable1, null, null);
		setTabSelection(0);

		// TestinAgentConfig tconfig = new TestinAgentConfig.Builder(this)
		// .withReportOnlyWifi(true) // 仅在 WiFi 下上报崩溃信息
		// .withQAMaster(false) // 开启摇一摇反馈
		// .build();
		// TestinAgent.init(tconfig);

	}

	@Override
	public void onResume() {
		com.baidu.mobads.appoffers.OffersManager.getPoints(this);
		if (appContext.isLogin()) {
			initChannel();
		}
		super.onResume();
	}

	@Override
	public void loadData(Map<String, String> param) {
		if (appContext.isLogin()) {
			LoginActivity.afterLogined(activity, new CheckBind() {
				@Override
				public void checkBind(String phone) {
					if (!appContext.isLogin()) {
						appContext.Logout("MainActivity");
					}
				}
			});
		} else {
			appContext.Logout("MainActivity");
		}
		AlphaAnimation aa = new AlphaAnimation(0.2f, 1.0f);
		aa.setDuration(2000);
		appStart.startAnimation(aa);
		aa.setAnimationListener(new AnimationListener() {
			@Override
			public void onAnimationEnd(Animation arg0) {
				appStart.setVisibility(View.GONE);
				appSpBack.setVisibility(View.GONE);
				appSplash.setVisibility(View.GONE);

				// 网络连接判断
				if (!appContext.isNetworkConnected()) {
					UIUtil.ToastMessage(appContext, "未连接网络！");
				}
				// 检查新版本
				if (appContext.isCheckUp() && appContext.isNetworkConnected()) {
					UpdateManager.getUpdateManager().checkAppUpdate(activity,
							false);
				}
			}

			@Override
			public void onAnimationRepeat(Animation animation) {
			}

			@Override
			public void onAnimationStart(Animation animation) {
			}

		});
	}

	@Override
	public void clearData() {
	}

	public void chooseMenu(int index) {
		if (currIndex != index)
			setTabSelection(index);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.main_fragment_linggan:
			if (currIndex != 0)
				setTabSelection(0);
			break;
		case R.id.main_fragment_faxian:
			if (currIndex != 1)
				setTabSelection(1);
			break;
		case R.id.main_fragment_tandian:
			if (currIndex != 2)
				setTabSelection(2);
			break;
		case R.id.main_fragment_wode:
			if (currIndex != 3)
				setTabSelection(3);
			break;
		default:
			break;
		}

	}

	@SuppressLint("CommitTransaction")
	private void setTabSelection(int index) {
		// int one = offset * 2 + bmpW;
		// 开启一个Fragment事务
		FragmentTransaction transaction = fragmentManager.beginTransaction();
		// 先隐藏掉所有的Fragment，以防止有多个Fragment显示在界面上的情况
		hideFragments(transaction);
		currIndex = index;
		textView1.setTextColor(getResources().getColor(R.color.color_64));
		textView2.setTextColor(getResources().getColor(R.color.color_64));
		textView3.setTextColor(getResources().getColor(R.color.color_64));
		textView4.setTextColor(getResources().getColor(R.color.color_64));
		Drawable drawable1 = getResources().getDrawable(R.drawable.menu_1);
		drawable1.setBounds(0, 0, drawable1.getMinimumWidth(),
				drawable1.getMinimumHeight());
		textView1.setCompoundDrawables(null, drawable1, null, null);
		Drawable drawable2 = getResources().getDrawable(R.drawable.menu_2);
		drawable2.setBounds(0, 0, drawable2.getMinimumWidth(),
				drawable2.getMinimumHeight());
		textView2.setCompoundDrawables(null, drawable2, null, null);
		Drawable drawable3 = getResources().getDrawable(R.drawable.menu_3);
		drawable3.setBounds(0, 0, drawable3.getMinimumWidth(),
				drawable3.getMinimumHeight());
		textView3.setCompoundDrawables(null, drawable3, null, null);
		Drawable drawable4 = getResources().getDrawable(R.drawable.menu_4);
		drawable4.setBounds(0, 0, drawable4.getMinimumWidth(),
				drawable4.getMinimumHeight());
		textView4.setCompoundDrawables(null, drawable4, null, null);
		switch (index) {
		case 0:
			if (fragment1 == null) {
				// 如果MessageFragment为空，则创建一个并添加到界面上
				fragment1 = new LingGanFragment();
				transaction.add(R.id.main_viewpager, fragment1);
			} else {
				// 如果MessageFragment不为空，则直接将它显示出来
				transaction.show(fragment1);
			}
			textView1.setTextColor(getResources()
					.getColor(R.color.color_e95847));
			drawable1 = getResources().getDrawable(R.drawable.menu_1_hover);
			drawable1.setBounds(0, 0, drawable1.getMinimumWidth(),
					drawable1.getMinimumHeight());
			textView1.setCompoundDrawables(null, drawable1, null, null);
			break;
		case 1:
			if (fragment2 == null) {
				// 如果MessageFragment为空，则创建一个并添加到界面上
				fragment2 = new FaXianFragment();
				transaction.add(R.id.main_viewpager, fragment2);
			} else {
				// 如果MessageFragment不为空，则直接将它显示出来
				transaction.show(fragment2);
			}
			textView2.setTextColor(getResources()
					.getColor(R.color.color_e95847));
			drawable2 = getResources().getDrawable(R.drawable.menu_2_hover);
			drawable2.setBounds(0, 0, drawable2.getMinimumWidth(),
					drawable2.getMinimumHeight());
			textView2.setCompoundDrawables(null, drawable2, null, null);
			break;
		case 2:
			if (fragment3 == null) {
				// 如果MessageFragment为空，则创建一个并添加到界面上
				fragment3 = new TanDianFragment();
				transaction.add(R.id.main_viewpager, fragment3);
			} else {
				// 如果MessageFragment不为空，则直接将它显示出来
				transaction.show(fragment3);
			}
			textView3.setTextColor(getResources()
					.getColor(R.color.color_e95847));
			drawable3 = getResources().getDrawable(R.drawable.menu_3_hover);
			drawable3.setBounds(0, 0, drawable3.getMinimumWidth(),
					drawable3.getMinimumHeight());
			textView3.setCompoundDrawables(null, drawable3, null, null);
			break;
		case 3:
			if (fragment4 == null) {
				// 如果MessageFragment为空，则创建一个并添加到界面上
				fragment4 = new FenxianZuanFragment();
				transaction.add(R.id.main_viewpager, fragment4);
			} else {
				// 如果MessageFragment不为空，则直接将它显示出来
				transaction.show(fragment4);
			}
			textView4.setTextColor(getResources()
					.getColor(R.color.color_e95847));
			drawable4 = getResources().getDrawable(R.drawable.menu_4_hover);
			drawable4.setBounds(0, 0, drawable4.getMinimumWidth(),
					drawable4.getMinimumHeight());
			textView4.setCompoundDrawables(null, drawable4, null, null);
			break;
		}
		transaction.commit();
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		boolean flag = true;
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			UIUtil.Exit(this);
		} else if (keyCode == KeyEvent.KEYCODE_MENU) {
			// 展示快捷栏
			// if(!mDrawerLayout.isShown())mDrawerLayout.openDrawer(Gravity.LEFT);
			// mDrawerLayout.openDrawer(Gravity.LEFT);
		} else if (keyCode == KeyEvent.KEYCODE_SEARCH) {
			// 展示搜索页
			// UIHelper.showSearch(MainActivity.this);
		} else if (keyCode == KeyEvent.KEYCODE_HOME) {

		} else {
			flag = super.onKeyDown(keyCode, event);
		}
		return flag;
	}

	private void hideFragments(FragmentTransaction transaction) {
		if (fragment1 != null) {
			transaction.hide(fragment1);
		}
		if (fragment2 != null) {
			transaction.hide(fragment2);
		}
		if (fragment3 != null) {
			transaction.hide(fragment3);
		}
		if (fragment4 != null) {
			transaction.hide(fragment4);
		}
	}

	public class ViewPagerAdapter extends PagerAdapter {

		// 界面列表
		private List<View> views;

		public ViewPagerAdapter(List<View> views) {
			this.views = views;
		}

		// 销毁arg1位置的界面
		@Override
		public void destroyItem(View arg0, int arg1, Object arg2) {
			((ViewPager) arg0).removeView(views.get(arg1));
		}

		// 获得当前界面数
		@Override
		public int getCount() {
			if (views != null) {
				return views.size();
			}

			return 0;
		}

		// 初始化arg1位置的界面
		@Override
		public Object instantiateItem(View arg0, int arg1) {

			((ViewPager) arg0).addView(views.get(arg1), 0);

			return views.get(arg1);
		}

		// 判断是否由对象生成界面
		@Override
		public boolean isViewFromObject(View arg0, Object arg1) {
			return (arg0 == arg1);
		}

	}

	public static void initDown() {
		try {
			fragment1.initDown();
		} catch (Exception e) {
		}
		try {
			fragment3.initDown();
		} catch (Exception e) {
		}
	}

	public static void fragementFreash() {
		if (fragment1 != null && !fragment1.isHidden()) {
			try {
				fragment1.initme();
			} catch (Exception e) {
			}
		}
		if (fragment2 != null && !fragment2.isHidden()) {
			try {
				// fragment2.onResume();
			} catch (Exception e) {
			}
		}
		if (fragment3 != null && !fragment3.isHidden()) {
			try {
				// TanDianFragment.freshPage=true;
				// fragment3.onResume();
			} catch (Exception e) {
			}
		}
		if (fragment4 != null && !fragment4.isHidden()) {
			try {
				fragment4.onResume();
			} catch (Exception e) {
			}
		}
	}

	@Override
	protected void onDestroy() {
		if (isCanDistroy()) {
			OffersManager.getInstance(this).onAppExit();
		}
		super.onDestroy();

	}

	/****************************************************/
	/* 获取积分回调 点入 */
	/* score : 积分 */
	/****************************************************/
	@Override
	public void scoreResultCallback(int score) {
		AlertDialog.Builder dialog = new AlertDialog.Builder(this,
				AlertDialog.THEME_HOLO_LIGHT);
		dialog.setTitle("显示积分结果");
		dialog.setMessage("" + score);
		dialog.setPositiveButton("确定", null);
		dialog.setCancelable(false);
		dialog.show();
	}

	/****************************************************/
	/* 消费积分回调 点入 */
	/* status : true 消费成功, false 消费失败 */
	/****************************************************/
	@Override
	public void spendScoreCallback(boolean status) {
		AlertDialog.Builder dialog = new AlertDialog.Builder(this,
				AlertDialog.THEME_HOLO_LIGHT);
		dialog.setTitle("消费积分结果");
		dialog.setMessage(status ? "消费成功" : "余额不足");
		dialog.setPositiveButton("确定", null);
		dialog.show();
	}

	@Override
	public void onFailedToReceiveAd() {

	}

	@Override
	public void onReceiveAd() {

	}

}
